home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / gimp / 2.0 / plug-ins / palette-to-gradient.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.4 KB  |  42 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from gimpfu import *
  5. gettext.install('gimp20-python', gimp.locale_directory, unicode = True)
  6.  
  7. def make_gradient(palette, num_segments, num_colors):
  8.     gradient = pdb.gimp_gradient_new(palette)
  9.     pdb.gimp_gradient_segment_range_split_uniform(gradient, 0, -1, num_segments)
  10.     for color_number in range(0, num_segments):
  11.         if color_number == num_colors - 1:
  12.             color_number_next = 0
  13.         else:
  14.             color_number_next = color_number + 1
  15.         color_left = pdb.gimp_palette_entry_get_color(palette, color_number)
  16.         color_right = pdb.gimp_palette_entry_get_color(palette, color_number_next)
  17.         pdb.gimp_gradient_segment_set_left_color(gradient, color_number, color_left, 100)
  18.         pdb.gimp_gradient_segment_set_right_color(gradient, color_number, color_right, 100)
  19.     
  20.     pdb.gimp_context_set_gradient(gradient)
  21.     return gradient
  22.  
  23.  
  24. def palette_to_gradient_repeating(palette):
  25.     num_colors = pdb.gimp_palette_get_info(palette)
  26.     num_segments = num_colors
  27.     return make_gradient(palette, num_segments, num_colors)
  28.  
  29. register('python-fu-palette-to-gradient-repeating', N_('Create a repeating gradient using colors from the palette'), 'Create a new repeating gradient using colors from the palette.', 'Carol Spears, reproduced from previous work by Adrian Likins and Jeff Trefftz', 'Carol Spears', '2006', N_('Palette to _Repeating Gradient'), '', [
  30.     (PF_PALETTE, 'palette', _('Palette'), '')], [
  31.     (PF_GRADIENT, 'new-gradient', 'Result')], palette_to_gradient_repeating, menu = '<Palettes>', domain = ('gimp20-python', gimp.locale_directory))
  32.  
  33. def palette_to_gradient(palette):
  34.     num_colors = pdb.gimp_palette_get_info(palette)
  35.     num_segments = num_colors - 1
  36.     return make_gradient(palette, num_segments, num_colors)
  37.  
  38. register('python-fu-palette-to-gradient', N_('Create a gradient using colors from the palette'), 'Create a new gradient using colors from the palette.', 'Carol Spears, reproduced from previous work by Adrian Likins and Jeff Trefftz', 'Carol Spears', '2006', N_('Palette to _Gradient'), '', [
  39.     (PF_PALETTE, 'palette', _('Palette'), '')], [
  40.     (PF_GRADIENT, 'new-gradient', 'Result')], palette_to_gradient, menu = '<Palettes>', domain = ('gimp20-python', gimp.locale_directory))
  41. main()
  42.